package db

import (
	"database/sql"
	"time"
	"ulcdkey/conf"

	_ "github.com/go-sql-driver/mysql"
)

var db *sql.DB

func init() {
	var err error
	db, err = sql.Open("mysql", conf.Conf.Mysql)
	if err != nil {
		panic(err)
	}
	if err = db.Ping(); err != nil {
		panic(err.Error())
	}

	//加载缓存
	LoadAllCache()
	db.SetConnMaxLifetime(4 * time.Hour)

}
